package com.liusaidh.domain;

import java.time.LocalDate;
import java.util.Date;
import java.util.Random;

public class User {
    private Integer id;
    private String username;//昵称
    private String password;
    private String email;
    private Integer age;
    private char sex;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                ", entryDate='" + entryDate + '\'' +
                ", address='" + address + '\'' +
                ", official=" + official +
                ", vip=" + vip +
                ", exit=" + exit +
                ", ban=" + ban +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", backgroundUrl='" + backgroundUrl + '\'' +
                '}';
    }

    public User(Integer id, String username, String password, String email, Integer age, char sex, String entryDate, String address, Integer official, Integer vip, Integer exit, Integer ban, String avatarUrl, String backgroundUrl) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.email = email;
        this.age = age;
        this.sex = sex;
        this.entryDate = entryDate;
        this.address = address;
        this.official = official;
        this.vip = vip;
        this.exit = exit;
        this.ban = ban;
        this.avatarUrl = avatarUrl;
        this.backgroundUrl = backgroundUrl;
    }

    private String entryDate;
    private String address;


    public User(Integer id,String email ,String password) {
        this.id = id;
        this.password = password;
        this.email = email;
    }

    public User() {
    }

    //     官方认证：official（1代表认证  0代表不是认证，也没有申请认证  2代表申请了认证，但是要管理员审核）
    private Integer official;//是否认证
    // 会员:vip  (int类型  1代表是  0代表不是)
    private Integer vip;
//    是否已注销：logout （1代表注销 0代表没注销）
    private Integer exit;
//    是否被管理员禁言：ban（1代表被禁言  0代表未被禁言）
    private Integer ban;//是否被禁止
    private String avatarUrl;
    private String backgroundUrl;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        if (username != null && username != ""){
            this.username = username;
        }else{
            Random random = new Random();
            int randomNumber = random.nextInt(100000000) + 100000000;
            this.username = "user_" + String.valueOf(randomNumber);
        }
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public String getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(String entryDate) {
        LocalDate currentDate = LocalDate.now();
        this.entryDate = String.valueOf(currentDate);
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getOfficial() {
        return official;
    }

    public void setOfficial(Integer official) {
        if (official != null){
            this.official = official;
        }else{
            this.official = 0;
        }
    }

    public Integer getVip() {
        return vip;
    }

    public void setVip(Integer vip) {
        if (vip != null){
            this.vip = vip;
        }else{
            this.vip = 0;
        }
    }

    public Integer getExit() {
        return exit;
    }

    public void setExit(Integer exit) {
        if (exit != null){
            this.exit = exit;
        }else{
            this.exit = 0;
        }
    }

    public Integer getBan() {
        return ban;
    }

    public void setBan(Integer ban) {
        if (ban != null){
            this.ban = ban;
        }else{
            this.ban = 0;
        }
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        if (avatarUrl != null && avatarUrl != ""){
            this.avatarUrl = avatarUrl;
        }else {
            this.avatarUrl = "static/img/default.";//设置默认的头像
        }
    }

    public String getBackgroundUrl() {
        return backgroundUrl;
    }

    public void setBackgroundUrl(String backgroundUrl) {
        if (backgroundUrl != null && backgroundUrl != ""){
            this.backgroundUrl = backgroundUrl;
        }else {
            this.backgroundUrl = "static/img/default.";//设置默认的背景
        }
    }
}
